package com.aierkeji.call.cms.service;

import java.io.File;
import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class AkjCallScheduled {
	private final Logger log = LogManager.getLogger(getClass());

	@Autowired
	AkjCallClueService akjCallClueService;
	Boolean assigneRecycleFlag = false;
	Boolean assigneBackUpsFlag = false;

	/*
	 * 线索回收
	 */
	@Scheduled(cron = "0 0 1 * * ?")
	public void assigneRecycle() {
		log.info("=====>>>>>使用assigneRecycle start {},{}", System.currentTimeMillis(), assigneRecycleFlag);

		if (assigneRecycleFlag)
			return;
		assigneRecycleFlag = true;
		try {

			akjCallClueService.assigneRecycle();
		} catch (Exception e) {
			// TODO: handle exception
			log.error("", e);
		}

		assigneRecycleFlag = false;
		log.info("=====>>>>>使用assigneRecycle end {},{}", System.currentTimeMillis(), assigneRecycleFlag);
	}
	/*
	 * 线索备份
	 */
	@Scheduled(cron = "0 0 2 * * ?")
	public void assigneBackUps() {
		log.info("=====>>>>>使用assigneBackUps start {},{}", System.currentTimeMillis(), assigneBackUpsFlag);

		if (assigneBackUpsFlag)
			return;
		assigneBackUpsFlag = true;
		try {

			akjCallClueService.assigneBackUps();
		} catch (Exception e) {
			// TODO: handle exception
			log.error("", e);
		}

		assigneBackUpsFlag = false;
		log.info("=====>>>>>使用assigneBackUps end {},{}", System.currentTimeMillis(), assigneBackUpsFlag);
	}
	
}
